package interpreter

import (
	"parse/src/token"
)

// 最基本的数据类型
type BaseData struct {
	PosStart *token.Position
	PosEnd   *token.Position
	Context  *Context
	//BaseValue  interface{}
}

// 实例化value
func NewBaseData() *BaseData {
	temp := &BaseData{}
	temp.InitBaseData()
	return temp
}

// 初始化
func (v *BaseData) InitBaseData() {
	v.SetPos(nil, nil)
	v.SetContext(nil)
}

// 设置位置
func (v *BaseData) SetPos(posStart *token.Position, posEnd *token.Position) interface{} {
	v.PosStart = posStart
	v.PosEnd = posEnd
	return v
}

// 设置内容
func (v *BaseData) SetContext(context *Context) *BaseData {
	v.Context = context
	return v
}

// 加上去
func (v *BaseData) AddedTo(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 减
func (v *BaseData) SubbedBy(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) MultedBy(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) DivedTo(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) PowedBy(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonEq(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonNe(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonLt(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonGt(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonLte(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) GetComparisonGte(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) AndedBy(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) OredBy(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 非
func (v *BaseData) Notted(other interface{}) (interface{}, interface{}) {
	return nil, v.IllegalOperation(other)
}

// 乘
func (v *BaseData) Execute(other interface{}) (interface{}, interface{}) {
	// 报错
	// todo
	return nil, nil
}

// 乘
func (v *BaseData) Copy(other interface{}) interface{} {
	// 报错
	// todo
	return nil
}

// 非法操作
func (v *BaseData) IllegalOperation(other interface{}) *RTError {
	if other != nil {
		other = v
	}
	// 此处有语法错误，表示是抛出的异常
	return NewRTError(v.PosStart, v.PosEnd, "非法操作", v.Context)
}
